from flask_socketio import emit

from app import socketio


# 情况1
@socketio.on('message')
def handle_message(data):
    print('received message: ' + data)


@socketio.on('my_text', namespace='/receMess')
def handle_message(data):
    # 测试5client.py的client端接收数据，失败用class-based Namespace
    # sio.emit('event_to_client', "data['name']")
    # 测试1跑通
    print('////')
    # 测试2 str(data)可以
    # print('received message: ' + str(data))
    # 测试3JSON,必须通过['key']获取value
    print('received message: ' + data['name'])
    # 测试4web页面显示跑通
    emit('message', {'msg': 'hellojuran'})
